/*
 * User: user
 * Date: 28/12/2007
 * Time: 17:58:20
 */
package org.conann.metadata.records;

import static com.google.common.base.Preconditions.checkArgument;
import net.jcip.annotations.Immutable;

import java.lang.reflect.AnnotatedElement;
import java.util.List;

@Immutable
public abstract class BehaviorRecord<T extends AnnotatedElement> extends Record<T> {

    private final List<Parameter<T>> params;

    @SuppressWarnings({"AbstractMethodCallInConstructor", "OverridableMethodCallDuringObjectConstruction"})
    protected BehaviorRecord(T element) {
        super(element);
        params = resolveParameters();
    }

    protected abstract List<Parameter<T>> resolveParameters();

    public Parameter<T> getParameter(int index) {
        checkArgument(params.size() >= index);
        return params.get(index);
    }

    public List<Parameter<T>> getParameters() {
        return params;
    }
}